package com.rongshu.view.userInfo.presenter;

import android.content.Context;

import com.rongshu.api.RetorfitService;
import com.rongshu.view.base.mvp.BasePresenter;
import com.rongshu.view.base.mvp.INetBean;
import com.rongshu.view.userInfo.entity.PrivacyInfo;
import com.rongshu.view.userInfo.iview.PushNotificationView;

import rx.Subscriber;

public class PushNotificationPresenter extends BasePresenter<PushNotificationView> {

    public PushNotificationPresenter(Context context) {
        super(context);
    }

    /**
     * 获取隐私设置/消息推送设置
     */
    public void getPrivacy(int user_id, String sign) {
        RetorfitService.getPrivacy(user_id, sign)
                .subscribe(new Subscriber<PrivacyInfo>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(PrivacyInfo privacyInfo) {
                        if (getView() != null) {
                            getView().onPrivacyInfo(privacyInfo);
                        }
                    }
                });
    }

    /**
     * 消息推送设置
     */
    public void setMsgPush(int user_id, int push_zan, int push_pinglun, int push_aite,
                           int push_wenzhang, int push_send, String sign) {
        RetorfitService.getMsgPush(user_id, push_zan, push_pinglun, push_aite, push_wenzhang, push_send, sign)
                .subscribe(new Subscriber<INetBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(INetBean bean) {
                        if (getView() != null) {
                            getView().onMsgPush(bean);
                        }
                    }
                });
    }
}
